package com.techsen.tsweb.sys.web.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.techsen.tsweb.core.domain.JsonResult;
import com.techsen.tsweb.sys.domain.Company;
import com.techsen.tsweb.sys.service.CompanyService;

@Controller
@RequestMapping("/sys/company")
public class CompanyController {

    @Resource
    private CompanyService companyService;
    
    /**
     * 查看公司
     */
    @RequestMapping("/orgid/{orgId}")
    public String view(@PathVariable("orgId") String orgId, Model model) {
        Company company = this.companyService.getOneByEntity(new Company().setOrgId(orgId));
        model.addAttribute("company", company);
        return "sys/company-view";
    }
    
    /**
     * 修改公司
     */
    @RequestMapping("/update")
    public @ResponseBody JsonResult update(Company company) {
        this.companyService.update(company);
        return new JsonResult(company);
    }
    
}
